-- Function: autenticarcliente(character varying, integer)

-- DROP FUNCTION autenticarcliente(character varying, integer);


CREATE OR REPLACE FUNCTION autenticarcliente(IN pass character varying, IN num_documento integer)
RETURNS boolean AS 
$BODY$

DECLARE

resultado boolean;
registro_encontrado integer;

BEGIN

registro_encontrado := 0;

SELECT  count(*) into registro_encontrado from cliente c where c.numero_documento = num_documento and c.clave = pass;

if(registro_encontrado > 0) then 
	resultado := true;
	
else
	resultado := false;
	
end if;

return resultado;

END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION autenticarcliente(character varying, integer)
  OWNER TO postgres;